package servlet.rool;

import net.sf.json.JSONObject;
import service.MenuService;
import service.impl.MenuServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * 删除菜单的servlet
 */
@WebServlet(value = "/MenuDeleServlet")
public class MenuDeleServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        MenuService ms=new MenuServiceImpl();
        int bo=ms.deleMenu(Integer.parseInt(request.getParameter("id")));
        JSONObject json=new JSONObject();
        if(bo>0){
            json.put("msg","删除成功");
        }else {
            json.put("msg","删除失败");
        }
        PrintWriter out=response.getWriter();
        out.print(json);
    }
    
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 
        doGet(request, response);
    }
}
